package com.ht.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ht.dto.MedicationDiary;
import com.ht.mapper.MedicationDiaryMapper;
import com.ht.service.IMedicationDiaryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 代齐园
 * @since 2022-05-28
 */
@Service
public class MedicationDiaryServiceImpl extends ServiceImpl<MedicationDiaryMapper, MedicationDiary> implements IMedicationDiaryService {

    @Resource
    private MedicationDiaryMapper medicationDiaryMapper;

    @Override
    public void insertDiary(Long id,MedicationDiary medicationDiary) {
        medicationDiary.setUserId(id);
        medicationDiaryMapper.insert(medicationDiary);
    }

    @Override
    public List<MedicationDiary> getMyDiary(Long id) {
        QueryWrapper<MedicationDiary> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",id);
        List<MedicationDiary> medicationDiaries = medicationDiaryMapper.selectList(queryWrapper);
        return medicationDiaries;
    }

}
